/*
 * Copyright (c) 2016 sinoiov.com. All Rights Reserved.
 */

package org.mybatis.gr;


import org.mybatis.generator.api.ShellRunner;

import java.io.UnsupportedEncodingException;
import java.net.URL;

public class GenerateOrm {
	
	public void generate() throws UnsupportedEncodingException, Exception{
//		String className = "org.mybatis.generator.internal.db.DatabaseIntrospector";
//		Thread.currentThread().getContextClassLoader().loadClass(className);
		URL urlPath = this.getClass().getClassLoader().getResource("mybatisGenerator.xml");
		String path = urlPath.toString();
		path = java.net.URLDecoder.decode(path, "UTF-8");
		String filePrefix = "file:";
		path = path.substring(filePrefix.length());
		String[] args= {"-configfile",path,"-overwrite"};
		ShellRunner.main(args);
	}
	
	public static void main(String[] args) throws Exception{
		new GenerateOrm().generate();
	}

}
